/*************************************************************************
> File Name: 01_test.cpp
> Author: hzy
> Created Time: 2023-08-10 11:29:51
> Description: 对象的创建
************************************************************************/
#include <iostream>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

class Demo
{
public:
    Demo()
    {
        cout << "Demo()" << endl;
        p = (char *)malloc(10);
        strcpy(p, "猪猪");
    }
    ~Demo()
    {
        cout << "~Demo()" << endl;
        if (p != NULL)
        {
            delete p;
            p = NULL;
        }
    }

    void show()
    {
        cout << "p = " << p << endl;
    }

private:
    char *p;
};

int main()
{
    Demo *q = new Demo;

    q->show();

    delete q;

    return 0;
}